﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentDefinition
{
    public class StudentPrivateInfo :ICloneable
    {
        public string Firstname { get; set; }
        public string Middlename { get; set; }
        public string LastName { get; set; }
        public string SSN { get; set; }
        public string PermanentAddess { get; set; }
        public string Email { get; set; }
        public string MobilePhone { get; set; }
        public string Fullname
        {
            get
            {
                string fullName = this.Firstname + this.Middlename + this.LastName+this.SSN;
                return fullName;
            }
        }

        public StudentPrivateInfo(string firstname,
                                  string middlename,
                                  string lastName,
                                  string sSN,
                                  string permanentAddess,
                                  string email,
                                  string mobilePhone)
        {
            this.Firstname = firstname;
            this.Middlename = middlename;
            this.LastName = lastName;
            this.SSN = sSN;
            this.PermanentAddess = permanentAddess;
            this.Email = email;
            this.MobilePhone = mobilePhone;
        }

        public object Clone()
        {
            StudentPrivateInfo newStudentPrivateInfo = new StudentPrivateInfo(
                this.Firstname, 
                this.Middlename,
                this.LastName,
                this.SSN,
                this.PermanentAddess,
                this.Email,
                this.MobilePhone
            );
            return newStudentPrivateInfo;
        }

        public override string ToString()
        {
            return string.Format(
                "Firstname: {0}, Middlename: {1}, LastName: {2}, SSN: {3}, PermanentAddess: {4}, Email: {5}, MobilePhone: {6}",
                Firstname,
                Middlename,
                LastName,
                SSN,
                PermanentAddess,
                Email,
                MobilePhone);
        }

        public override bool Equals(object obj)
        {
            StudentPrivateInfo temp = obj as StudentPrivateInfo;
            if (temp == null) return false;
            return this.Equals(temp);
        }

        private bool Equals(StudentPrivateInfo value)
        {
            return Equals(this.Firstname, value.Firstname) &&
                   Equals(this.Middlename, value.Middlename) &&
                   Equals(this.LastName, value.LastName) &&
                   Equals(this.SSN, value.SSN) &&
                   Equals(this.PermanentAddess, value.PermanentAddess) &&
                   Equals(this.Email, value.Email) &&
                   Equals(this.MobilePhone, value.MobilePhone);
        }

        public override int GetHashCode()
        {
            int result = Firstname.GetHashCode() ^ Middlename.GetHashCode() ^ LastName.GetHashCode() ^ SSN.GetHashCode() ^
                PermanentAddess.GetHashCode() ^ Email.GetHashCode() ^ MobilePhone.GetHashCode();
            return result;
        }

    }
}
